package org.whut.practice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.whut.practice.pojo.GPS;
import org.whut.practice.service.GpsService;
import org.whut.practice.utils.Response;

import java.util.Map;

@Controller
public class GpsController {

    @Autowired
    GpsService gpsService;

    @ResponseBody
    @PostMapping("/gps")
    public Map<String, Object> addGps(@RequestBody GPS gps) {
        int count = gpsService.addGps(gps);
        return count > 0 ? Response.makeOkResponse(count, "Successfully add gps data") :
                Response.makeErrorResponse("Failed to add gps data");
    }

}
